const app = getApp();
var utils = require('../../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    currPage: 1,
    loadingMoreHidden: 1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {

    if (options.status == 1) {
      wx.setNavigationBarTitle({
        title: '已确认'
      })
    }
    if (options.status == 2) {
      wx.setNavigationBarTitle({
        title: '已拒绝'
      })
    }
    this.getMyPayRequests(options.status);
  },

  copyData: function(e){
    let mobile = e.currentTarget.dataset.copy;
    mobile = mobile.toString();
    utils.copyData(mobile,'手机号')
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  //获取已确认列表
  getMyPayRequests: function(status) {
    let that = this;
    wx.request({
      url: app.globalData.host + '/api/Staff/GetMyPayRequests?uid=' + app.globalData.userInfo.Uid + '&status=' + status + '&page=' + that.data.currPage,
      success: function(res) {
        if (res.data.Code == 0) {
          let list = res.data.Data;
          for (let i = 0; i < list.length; i++) {
            list[i].reqDate = list[i].RequestTime.substr(0, 10);
            list[i].reqTime = list[i].RequestTime.substr(11);
          }
          if (that.data.currPage != 1) {
            var preList = that.data.lists
            list = preList.concat(list);
          }
          that.setData({
            list: list
          })
        }
      }
    })
  },
  // 加载更多
  loadMore: function(e) {
    var that = this;
    if (that.data.loadingMoreHidden > 1 && that.data.currPage < that.data.loadingMoreHidden) {
      var currPage = that.data.currPage;
      that.setData({
        currPage: currPage + 1
      })
      that.getMyPayRequests();
    }
  },
})